package me.ohaga
{
	import net.flashpunk.Entity;
	import net.flashpunk.Graphic;
	import net.flashpunk.Mask;
	import net.flashpunk.Tween;
	import net.flashpunk.tweens.misc.NumTween;
	import net.flashpunk.utils.Draw;

	
	public class B extends Entity
	{
		
		public static const W:Number = 20;
		public static const H:Number = 20;
		
		private static const FADE_TIME:Number = 5;
		private var _t:NumTween = new NumTween(null, Tween.PERSIST);
		
		public function B(x:Number=0, y:Number=100, fadeTime:Number=FADE_TIME) {
			type = "b";
			this.x = x;
			this.y = y;
			setHitbox(W,H);
			_t.tween(1,0,fadeTime);
			addTween(_t,false);
		}
		
		public function start():void {
			if (!_t.active) {
				_t.start();
			}
		}
		
		override public function update():void {
			super.update();
			if (_t.value == 0) {
				(this.world as G).boom(this);
			}
		}
		
		override public function render():void {
			super.render();
			Draw.rect(x,y,W,H,G.COLOR,_t.value);
		}

	}
}